import { Component } from '@angular/core';
import { NgxEchartsModule } from 'ngx-echarts';
import * as $ from 'jquery';
import { Test1Component } from './components/test1/test1.component';
import {HttpClient} from "@angular/common/http";
export interface res {
  code: number;
  msg: string;
  data: object;
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'ang1';
  public anylist:any;
  public ans:any;
  public data:any;
  constructor(private http: HttpClient) {}
  ngOnInit(): void { this.http
    .get(`${this.preUrl}/getQuery`, { params: this.user })
    .subscribe((res) => {
      this.anylist = res;
      this.ans = res;
      console.log(res);
    });
    //Called after the constructor, initializing input properties, and the first call to ngOnChanges.
    //Add 'implements OnInit' to the class.
  }

  preUrl: string = 'http://127.0.0.1:8080/control';
  // TODO 在这里定义初始寻求entity的节点的id传入后端进行查询
  user: any = { name: 'entity/Q35120', id: 6, classname: 'Class One' };

  getQuery() {
    this.http
      .get(`${this.preUrl}/getQuery`, { params: this.user })
      .subscribe((res) => {
        this.anylist = res;
        console.log(res);
      });
  }
  getTree() {
    this.http
      .get(`${this.preUrl}/getTree`, { params: this.user })
      .subscribe((res) => {
        this.anylist = res;
        console.log(res);
      });
  }
  getName() {
    this.http
      .get(`${this.preUrl}/getName`, { params: this.user })
      .subscribe((res) => {
        this.data = res;
        console.log(res);
      });
  }
}
